import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:pornhub_app/assets/styles.dart';
import 'package:pornhub_app/components/app_bar/app_bar_view.dart';
import 'package:pornhub_app/components/image_view.dart';
import 'package:pornhub_app/components/text_view.dart';
import 'package:pornhub_app/model/message/mine_message_model.dart';
import 'package:pornhub_app/utils/color.dart';
import 'package:pornhub_app/utils/extension.dart';
import '../../../../components/no_more/no_data.dart';
import 'mine_message_page_controller.dart';

class MineMessagePage extends GetView<MineMessagePageController> {
  const MineMessagePage({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: COLOR.color_161616,
      appBar: AppBarView(
        titleText: "我的消息",
      ),
      body: EasyRefresh(
        refreshOnStart: true,
        controller: controller.refreshController,
        onRefresh: () {
          controller.onRefresh();
        },
        onLoad: () {
          controller.onLoad();
        },
        child: PagedListView<int, MineMessageModel>(
          padding: EdgeInsets.only(top: 20.w, left: 14.w, right: 14.w),
          addAutomaticKeepAlives: true,
          pagingController: controller.pagingControllers,
          builderDelegate: PagedChildBuilderDelegate<MineMessageModel>(
            firstPageProgressIndicatorBuilder: (context) =>
                const SizedBox.shrink(),
            newPageProgressIndicatorBuilder: (context) =>
                const SizedBox.shrink(),
            noMoreItemsIndicatorBuilder: (context) => const SizedBox.shrink(),
            noItemsFoundIndicatorBuilder: (context) => const NoData(),
            itemBuilder: (context, item, index) {
              return Container(
                margin: EdgeInsets.only(bottom: 24.w),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    ImageView(
                      src: "",
                      width: 44.w,
                      height: 44.w,
                      borderRadius: BorderRadius.circular(44.w),
                    ),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        TextView(
                          text: "游客007",
                          color: COLOR.white,
                          fontSize: 16.w,
                        ),
                        TextView(
                          text: "1小时前",
                          color: COLOR.white,
                          fontSize: 12.w,
                        ).marginOnly(top: 2.w, bottom: 6.w),
                        TextView(
                          text: "确实很美",
                          color: COLOR.white.withValues(alpha: 0.67),
                          fontSize: 14.w,
                        ),
                        Container(
                          width: 277.w,
                          height: 60.w,
                          margin: EdgeInsets.only(top: 10.w, bottom: 10.w),
                          padding: EdgeInsets.only(left: 8.w, right: 8.w),
                          alignment: Alignment.centerLeft,
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(4.w),
                              color: Color.fromRGBO(255, 255, 255, 0.1)),
                          child: Row(
                            children: [
                              ImageView(
                                src: "",
                                width: 50.w,
                                height: 50.w,
                                borderRadius: BorderRadius.circular(4.w),
                              ),
                              TextView(
                                text: "确实很美",
                                color: COLOR.white.withValues(alpha: 0.6),
                                fontSize: 14.w,
                              ).paddingLeft(8)
                            ],
                          ),
                        ),
                        Container(
                          height: 27.w,
                          width: 57.w,
                          alignment: Alignment.center,
                          // padding: EdgeInsets.only(left: 4.w, right: 4.w),
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(14.w),
                              color: Color.fromRGBO(255, 255, 255, 0.1)),
                          child: TextView(
                            text: "回复",
                            style: kTextStyle(
                                COLOR.white.withValues(alpha: 0.6),
                                fontsize: 12.w),
                          ),
                        )
                      ],
                    ).marginLeft(10.w)
                  ],
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}
